﻿' ----------------------------------------------------------------------
'
' FileSystemItem.vb
'
'   Dbfs.Entities
'
'   This class contains the fields of a FileSystemInfo object that are
'   potentially different from one layer of history to another.
'
' ----------------------------------------------------------------------
' version:  1.0.0.2
' today:    10/22/09  08:43:00
' ident:    "@(#)/Dbfs/Entities/FileSystemItem.vb 1.0 0.1 10/22/09 0 rjs"

Imports System.IO
Imports System.Security.AccessControl
Imports Dbfs.Security


Namespace Dbfs

    ''' <summary>
    ''' Exposes the fields and properties that are unique to a specific
    ''' historical version of a specific <see cref="FileSystemInfo"/> object.
    ''' </summary>
    ''' <remarks></remarks>
    <SerializableAttribute()> _
    Public Class FileSystemItem
        Implements ICloneable

        ' System.IO.FileSystemInfo class variables
        Public Name As Filename
        Public OriginalPath As String
        Public FullPath As String

        Public Attributes As FileAttributes
        Public CreationTimeUtc As Date
        Public LastAccessTimeUtc As Date
        Public LastWriteTimeUtc As Date

        ' DBFS extension variables
        Public EffectiveDateUtc As Date
        Public CancelDateUtc As Nullable(Of Date)
        Public DeleteTimeUtc As Nullable(Of Date)
        Public TrackChanges As Boolean

        ' object security
        Private _fileSystemSecurity As Security.FileSystemSecurity

        ' fields for internal class management
        Public Exists As Boolean


#Region "Constructors"
        ''' <summary>
        ''' Initializes a new instance of the <see cref="FileSystemItem"/> class.
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
            Name = New Filename
        End Sub

        ''' <summary>
        ''' Initializes a new instance of the <see cref="FileSystemItem"/> class on the specified path.
        ''' </summary>
        ''' <param name="Name">A string specifying the name of the <see cref="FileSystemItem"/>.</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal name As String)
            Me.Name = New Filename
            Me.Name.Value = name
        End Sub
#End Region

#Region " Properties "
        ''' <summary>
        ''' Gets or sets the <see cref="FileSystemSecurity"/> object the encapsulates the
        ''' access control list (ACL) entries for the object described by the current
        ''' <see cref="FileSystemItem"/> object.
        ''' </summary>
        ''' <value>A <see cref="FileSystemSecurity"/> object that encapsulates the 
        ''' access control rules for the filesystem item.</value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FileSystemSecurity() As Security.FileSystemSecurity
            Get
                If _fileSystemSecurity Is Nothing Then
                    _fileSystemSecurity = New DbfsDirectorySecurity()
                End If
                Return _fileSystemSecurity
            End Get
            Set(ByVal value As Security.FileSystemSecurity)
                _fileSystemSecurity = value
            End Set
        End Property
#End Region ' Properties

#Region " Methods "
        ''' <summary>
        ''' Creates a shallow copy of the current <see cref="FileSystemItem"/>.
        ''' </summary>
        ''' <returns>A shallow copy of the current <see cref="FileSystemItem"/>.</returns>
        ''' <remarks></remarks>
        Public Function Clone() As Object Implements System.ICloneable.Clone
            Return MemberwiseClone()
        End Function
#End Region ' Methods

    End Class

End Namespace


